Toni Verbeiren
processmap is synchronousIDMap to store parameters// Step - 7
process addTupleWithMap {
input:
tuple val(id), val(input), val(config)
output:
tuple val("${id}"), val(output)
exec:
output = (config.operator == "+")
? input + config.term
: input - config.term
}
workflow step7 {
Channel.from( [ 1, 2, 3 ] ) \
| map{ el ->
[
el.toString(),
el,
[ "operator" : "-", "term" : 10 ]
] } \
| addTupleWithMap \
| view{ it }
}Map with a process-key// Step - 8
process addTupleWithProcessHash {
input:
tuple val(id), val(input), val(config)
output:
tuple val("${id}"), val(output)
exec:
def thisConf = config.addTupleWithProcessHash
output = (thisConf.operator == "+")
? input + thisConf.term
: input - thisConf.term
}
workflow step8 {
Channel.from( [ 1, 2, 3 ] ) \
| map{ el ->
[
el.toString(),
el,
[ "addTupleWithProcessHash" :
[
"operator" : "-",
"term" : 10
]
]
] } \
| addTupleWithProcessHash \
| view{ it }
}ConfigMap with a shell script// Step - 9
process addTupleWithProcessHashScript {
input:
tuple val(id), val(input), val(config)
output:
tuple val("${id}"), stdout
script:
def thisConf = config.addTupleWithProcessHashScript
def operator = thisConf.operator
def term = thisConf.term
"""
echo \$( expr $input $operator ${thisConf.term} )
"""
}
workflow step9 {
Channel.from( [ 1, 2, 3 ] ) \
| map{ el ->
[
el.toString(),
el,
[ "addTupleWithProcessHashScript" :
[
"operator" : "-",
"term" : 10
]
]
] } \
| addTupleWithProcessHashScript \
| view{ it }
}// Step - 10
process process_step10a {
input:
tuple val(id), val(input), val(term)
output:
tuple val("${id}"), val(output), val("${term}")
exec:
output = input.toInteger() + term.toInteger()
}
process process_step10b {
input:
tuple val(id), val(input), val(term)
output:
tuple val("${id}"), val(output), val("${term}")
exec:
output = input.toInteger() - term.toInteger()
}
workflow step10 {
Channel.from( [ 1, 2, 3 ] ) \
| map{ el -> [ el.toString(), el, 10 ] } \
| process_step10a \
| process_step10b \
| view{ it }
}// Step - 11
process process_step11 {
input:
tuple val(id), val(input), val(config)
output:
tuple val("${id}"), val(output), val("${config}")
exec:
if (config.operator == "+")
output = input.toInteger() + config.term.toInteger()
else
output = input.toInteger() - config.term.toInteger()
}
workflow step11 {
Channel.from( [ 1, 2, 3 ] ) \
| map{ el -> [ el.toString(), el, [ : ] ] } \
| process_step11 \
| map{ id, value, config ->
[
id,
value,
[ "term" : 11, "operator" : "-" ]
] } \
| process_step11 \
| view{ [ it[0], it[1] ] }
}// Step - 11a
include { process_step11 as process_step11a } \
from './examples/modules/step11.nf'
include { process_step11 as process_step11b } \
from './examples/modules/step11.nf'
workflow step11a {
Channel.from( [ 1, 2, 3 ] ) \
| map{ el -> [ el.toString(), el, [ : ] ] } \
| map{ id, value, config ->
[
id,
value,
[ "term" : 5, "operator" : "+" ]
] } \
| process_step11a \
| map{ id, value, config ->
[
id,
value,
[ "term" : 11, "operator" : "-" ]
] } \
| process_step11b \
| view{ [ it[0], it[1] ] }
}// Step - 12
process process_step12 {
input:
tuple val(id), val(input), val(term)
output:
tuple val("${id}"), val(output), val("${term}")
exec:
output = input.sum()
}
workflow step12 {
Channel.from( [ 1, 2, 3 ] ) \
| map{ el -> [ el.toString(), el, 10 ] } \
| process_step10a \
| toList \
| map{
[
"sum",
it.collect{ id, value, config -> value },
[ : ]
] } \
| process_step12 \
| view{ [ it[0], it[1] ] }
}// Step - 13
process process_step13 {
input:
tuple val(id), file(input), val(config)
output:
tuple val("${id}"), file("output.txt"), val("${config}")
script:
"""
a=`cat $input`
let result="\$a + ${config.term}"
echo "\$result" > output.txt
"""
}
workflow step13 {
Channel.fromPath( params.input ) \
| map{ el ->
[
el.baseName.toString(),
el,
[ "operator" : "-", "term" : 10 ]
]} \
| process_step13 \
| view{ [ it[0], it[1] ] }
}// Step - 13
process process_step13 {
input:
tuple val(id), file(input), val(config)
output:
tuple val("${id}"), file("output.txt"), val("${config}")
script:
"""
a=`cat $input`
let result="\$a + ${config.term}"
echo "\$result" > output.txt
"""
}
workflow step13 {
Channel.fromPath( params.input ) \
| map{ el ->
[
el.baseName.toString(),
el,
[ "operator" : "-", "term" : 10 ]
]} \
| process_step13 \
| view{ [ it[0], it[1] ] }
}// Step - 15
process process_step15 {
publishDir "output/${config.id}"
input:
tuple val(id), file(input), val(config)
output:
tuple val("${id}"), file("output.txt"), val("${config}")
script:
"""
a=`cat $input`
let result="\$a + ${config.term}"
echo "\$result" > output.txt
"""
}
workflow step15 {
Channel.fromPath( params.input ) \
| map{ el ->
[
el.baseName,
el,
[
"id": el.baseName,
"operator" : "-",
"term" : 10
]
] } \
| process_step15 \
| view{ [ it[0], it[1] ] }
}params?params// Step - 17
process process_step17 {
publishDir "output"
input:
tuple val(id), file(input), val(config)
output:
tuple val("${id}"), file(params.output), val("${config}")
script:
"""
a=`cat $input`
let result="\$a + ${config.term}"
echo "\$result" > ${params.output}
"""
}
workflow step17 {
Channel.fromPath( params.input ) \
| map{ el ->
[
el.baseName.toString(),
el,
[
"id": el.baseName,
"operator" : "-",
"term" : 10
]
] } \
| process_step17 \
| view{ [ it[0], it[1] ] }
}// Step - 18
process process_step18 {
publishDir "output"
input:
tuple val(id), file(input), val(config)
output:
tuple val("${id}"), file("${config.output}"), val("${config}")
script:
"""
a=`cat $input`
let result="\$a + ${config.term}"
echo "\$result" > ${config.output}
"""
}
workflow step18 {
Channel.fromPath( params.input ) \
| map{ el -> [
el.baseName.toString(),
el,
[
"output" : "output_from_${el.baseName}.txt",
"id": el.baseName,
"operator" : "-",
"term" : 10
]
]} \
| process_step18 \
| view{ [ it[0], it[1] ] }
}// Step - 19
def out_from_in = { it -> it.baseName + "-out.txt" }
process process_step19 {
publishDir "output"
input:
tuple val(id), file(input), val(config)
output:
tuple val("${id}"), file("${out}"), val("${config}")
script:
out = out_from_in(input)
"""
a=`cat $input`
let result="\$a + ${config.term}"
echo "\$result" > ${out}
"""
}
workflow step19 {
Channel.fromPath( params.input ) \
| map{ el -> [
el.baseName.toString(),
el,
[
"id": el.baseName,
"operator" : "-",
"term" : 10
]
]} \
| process_step19 \
| view{ [ it[0], it[1] ] }
}// Step - 20a
process process_step20 {
input:
tuple val(id), val(input), val(term)
output:
tuple val("${id}"), val(output), val("${term}")
exec:
output = input[0] / input[1]
}
workflow step20a {
Channel.from( [ 1, 2 ] ) \
| map{ el -> [ el.toString(), el, 10 ] } \
| process_step10a \
| toList \
| map{ [
"sum",
it.collect{ id, value, config -> value },
[ : ]
] } \
| process_step20 \
| view{ [ it[0], it[1] ] }
}// Step - 22
process process_step22 {
publishDir "output"
input:
tuple val(id), file(input), val(config)
output:
tuple val("${id}"), file("${config.output}"), val("${config}")
script:
"""
${config.cli}
"""
}
workflow step22 {
Channel.fromPath( params.input ) \
| map{ el -> [
el.baseName.toString(),
el,
[
"cli": "cat input.txt > output22.txt",
"output": "output22.txt"
]
]} \
| process_step22 \
| view{ [ it[0], it[1] ] }
}
//- - -workflow instead of process```groovy
process cellranger_process {
...
container "${params.dockerPrefix}${container}"
publishDir "${params.output}/processed_data/${id}/", mode: 'copy', overwrite: true
input:
tuple val(id), path(input), val(output), val(container), val(cli)
output:
tuple val("${id}"), path("${output}")
script:
"""
export PATH="${moduleDir}:\$PATH"
$cli
"""
}```groovy
nextflow.preview.dsl=2
import java.nio.file.Paths
include plot_map from './target/nextflow/civ6_save_renderer/plot_map/main.nf' params(params)
include combine_plots from './target/nextflow/civ6_save_renderer/combine_plots/main.nf' params(params)
include convert_plot from './target/nextflow/civ6_save_renderer/convert_plot/main.nf' params(params)
include parse_header from './target/nextflow/civ6_save_renderer/parse_header/main.nf' params(params)
include parse_map from './target/nextflow/civ6_save_renderer/parse_map/main.nf' params(params)
include rename from './src/utils.nf'
workflow {
if (params.debug == true)
println(params)
if (!params.containsKey("input") || params.input == "") {
exit 1, "ERROR: Please provide a --input parameter pointing to .Civ6Save file(s)"
}
def input_ = Channel.fromPath(params.input)
def listToTriplet = { it -> [ "all", it.collect{ a -> a[1] }, params ] }
input_ \
| map{ it -> [ it.baseName , it ] } \
| map{ it -> [ it[0] , it[1], params ] } \
| ( parse_header & parse_map ) \
| join \
| map{ id, parse_headerOut, params1, parse_mapOut, params2 ->
[ id, [ "yaml" : parse_headerOut, "tsv": parse_mapOut ], params1 ] } \
| plot_map \
| convert_plot \
| rename \
| toSortedList{ a,b -> a[0] <=> b[0] } \
| map( listToTriplet ) \
| combine_plots
}